package com.liusy.code.templates;

import com.liusy.code.bean.*;

public class DaoImplTemplate
{
  protected static String nl;
  public static synchronized DaoImplTemplate create(String lineSeparator)
  {
    nl = lineSeparator;
    DaoImplTemplate result = new DaoImplTemplate();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "package ";
  protected final String TEXT_2 = ";" + NL + "" + NL + "import org.springframework.stereotype.Repository;" + NL + "" + NL + "import com.gdtopway.framework.basic.dao.impl.DefaultDataSourceDAO;" + NL + "import ";
  protected final String TEXT_3 = ".";
  protected final String TEXT_4 = ";" + NL + "import ";
  protected final String TEXT_5 = ".";
  protected final String TEXT_6 = ";" + NL + "import ";
  protected final String TEXT_7 = ".";
  protected final String TEXT_8 = ";" + NL + "" + NL + "@Repository(\"";
  protected final String TEXT_9 = "\")" + NL + "public class ";
  protected final String TEXT_10 = " extends" + NL + "\t\tDefaultDataSourceDAO<";
  protected final String TEXT_11 = ", String> implements ";
  protected final String TEXT_12 = " {" + NL + "}";
  protected final String TEXT_13 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
	JavaTemplateArgs args = (JavaTemplateArgs)argument;

    stringBuffer.append(TEXT_1);
    stringBuffer.append(args.getPackageName());
    stringBuffer.append(TEXT_2);
    stringBuffer.append(args.getPackageNameInfo().getDaoPackageName());
    stringBuffer.append(TEXT_3);
    stringBuffer.append(args.getClassNameInfo().getDaoClassName());
    stringBuffer.append(TEXT_4);
    stringBuffer.append(args.getPackageNameInfo().getServicPackageName());
    stringBuffer.append(TEXT_5);
    stringBuffer.append(args.getClassNameInfo().getServicClassName());
    stringBuffer.append(TEXT_6);
    stringBuffer.append(args.getPackageNameInfo().getEntityPackageName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_8);
    stringBuffer.append(args.getClassNameInfo().getDaoObjectName());
    stringBuffer.append(TEXT_9);
    stringBuffer.append(args.getClassNameInfo().getDaoClassNameImpl());
    stringBuffer.append(TEXT_10);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_11);
    stringBuffer.append(args.getClassNameInfo().getDaoClassName());
    stringBuffer.append(TEXT_12);
    stringBuffer.append(TEXT_13);
    return stringBuffer.toString();
  }
}
